home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / libg_261.zip / libg_261 / libg++ / src / gen / AVec.hP < prev    next >
Text File  |  1994-06-28  |  4KB  |  119 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Doug Lea (dl@rocky.oswego.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19.  
  20. #ifndef _<T>AVec_h
  21. #ifdef __GNUG__
  22. #pragma interface
  23. #endif
  24. #define _<T>AVec_h 1
  25.  
  26. #include "<T>.Vec.h"
  27.  
  28. class <T>AVec : public <T>Vec
  29. {
  30. protected:
  31.   void                  check_len(int l);
  32.   <T>*                  vec();
  33.   const <T>*        vec() const;
  34.                         <T>AVec(int l, <T>* d);
  35.   public:
  36.                         <T>AVec ();
  37.                         <T>AVec (int l);
  38.                         <T>AVec (int l, <T&> fill_value);
  39.                         <T>AVec (<T>AVec&);
  40.                         ~<T>AVec ();
  41.  
  42.   <T>AVec&              operator =  (const <T>AVec& a);
  43.   <T>AVec&              operator =  (<T&> fill_value);
  44.  
  45. // vector by scalar -> vector operations
  46.  
  47.   friend <T>AVec        operator +  (<T>AVec& a, <T&> b);
  48.   friend <T>AVec        operator -  (<T>AVec& a, <T&> b);
  49.   friend <T>AVec        operator *  (<T>AVec& a, <T&> b);
  50.   friend <T>AVec        operator /  (<T>AVec& a, <T&> b);
  51.  
  52.   <T>AVec&              operator += (<T&> b);
  53.   <T>AVec&              operator -= (<T&> b);
  54.   <T>AVec&              operator *= (<T&> b);
  55.   <T>AVec&              operator /= (<T&> b);
  56.  
  57. // vector by vector -> vector operations
  58.  
  59.   friend <T>AVec        operator +  (<T>AVec& a, <T>AVec& b);
  60.   friend <T>AVec        operator -  (<T>AVec& a, <T>AVec& b);
  61.   <T>AVec&              operator += (<T>AVec& b);
  62.   <T>AVec&              operator -= (<T>AVec& b);
  63.  
  64.   <T>AVec               operator - ();
  65.  
  66.   friend <T>AVec        product(<T>AVec& a, <T>AVec& b);
  67.   <T>AVec&              product(<T>AVec& b);
  68.   friend <T>AVec        quotient(<T>AVec& a, <T>AVec& b);
  69.   <T>AVec&              quotient(<T>AVec& b);
  70.  
  71. // vector -> scalar operations
  72.  
  73.   friend <T>            operator * (<T>AVec& a, <T>AVec& b);
  74.  
  75.   <T>                   sum();
  76.   <T>                   min();
  77.   <T>                   max();
  78.   <T>                   sumsq();
  79.  
  80. // indexing
  81.  
  82.   int                   min_index();
  83.   int                   max_index();
  84.  
  85. // redundant but necesssary
  86.   friend <T>AVec        concat(<T>AVec& a, <T>AVec& b);
  87.   friend <T>AVec        map(<T>Mapper f, <T>AVec& a);
  88.   friend <T>AVec        merge(<T>AVec& a, <T>AVec& b, <T>Comparator f);
  89.   friend <T>AVec        combine(<T>Combiner f, <T>AVec& a, <T>AVec& b);
  90.   friend <T>AVec        reverse(<T>AVec& a);
  91.   <T>AVec               at(int from = 0, int n = -1);
  92. };
  93.  
  94. inline <T>AVec::<T>AVec() {}
  95. inline <T>AVec::<T>AVec(int l) :<T>Vec(l) {}
  96. inline <T>AVec::<T>AVec(int l, <T&> fill_value) : <T>Vec (l, fill_value) {}
  97. inline <T>AVec::<T>AVec(<T>AVec& v) :<T>Vec(v) {}
  98. inline <T>AVec::<T>AVec(int l, <T>* d) :<T>Vec(l, d) {}
  99. inline <T>AVec::~<T>AVec() {}
  100.  
  101.  
  102. inline <T>* <T>AVec::vec()
  103. {
  104.   return s;
  105. }
  106.  
  107. inline const <T>* <T>AVec::vec() const
  108. {
  109.   return s;
  110. }
  111.  
  112. inline void <T>AVec::check_len(int l)
  113. {
  114.   if (l != len)
  115.     error("nonconformant vectors.");
  116. }
  117.  
  118. #endif
  119.